package commonClass.socket.stickPackage;

import java.io.DataInputStream;
import java.io.IOException;
import java.net.Socket;

public class SocketClient {
	/** 客户端尝试连接的次数 **/
	public static final int CONNECT_UNM = 1000;
	/** 服务器端IP **/
	public static final String SERVER_IP = "127.0.0.1";

	public static void main(String[] args) {

		for (int i = 1; i <= CONNECT_UNM; i++) {
			new Thread(new Runnable() {

				@Override
				public void run() {
					Socket s = null;
					try {
						s = new Socket(SERVER_IP, ThreadSocketServer.PORT);
						DataInputStream dIn = new DataInputStream(
								s.getInputStream());
						dIn.readByte();
						dIn.readByte();
						dIn.read();
						dIn.read();
						dIn.read();
						dIn.read();
						dIn.read();
						dIn.read();
						dIn.read();
						dIn.read();
						System.out.println(dIn.readUTF() + dIn.readUTF());

					} catch (Exception e) {
						e.printStackTrace();
					} finally {
						try {
							s.close();
						} catch (IOException e) {
						}
					}
				}
			}).start();

			try {
				Thread.sleep(1);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}

		}

	}

}
